package com.banshou.installs.utils;

import com.banshou.installs.constant.Config;
import com.blankj.utilcode.util.AppUtils;

import org.jetbrains.annotations.NotNull;

import io.reactivex.Maybe;
import io.reactivex.MaybeEmitter;
import io.reactivex.MaybeOnSubscribe;
import zlc.season.rxdownload3.core.RealMission;
import zlc.season.rxdownload3.extension.Extension;

/**
 * Created by cjq on 2018/4/12.
 * Email: stoic_yb@139.com
 * features:
 */
public class IApkInstallExtension implements Extension {
    private RealMission mission;

    @Override
    public void init(RealMission realMission) {
        this.mission = realMission;
    }

    @NotNull
    @Override
    public Maybe<Object> action() {
        return Maybe.create(e -> {
            AppUtils.installApp(mission.getFile().getAbsolutePath(), Config.AUTHORITY);
            e.onSuccess(1);
        });
    }
}
